package com.lsp.server.common.config;

import com.lsp.server.common.interceptor.CrossInterceptor;
import com.lsp.server.common.interceptor.JwtInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @ClassName CrossConfig
 * @Description 跨域配置文件
 * @Author Mr Hao
 * @Date 2021/11/15 17:52
 */
@Configuration
public class CrossConfig extends WebMvcConfigurationSupport {

    @Autowired
    private CrossInterceptor crossInterceptor;

    @Autowired
    private JwtInterceptor jwtInterceptor;

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        /*  注册跨域拦截器  */
        registry.addInterceptor(crossInterceptor).addPathPatterns("/**");
        /*  注册认证拦截器 */
        registry.addInterceptor(jwtInterceptor).addPathPatterns("/**").excludePathPatterns("/**");
    }
}